package crypto.test;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.security.Security;
import java.util.Date;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;

public class Check {

  public static void main(String[] args) throws Exception {

    System.out.println(new Date(1559062948164L));
    System.out.println("-------列出加密服务提供者-----");
    Provider[] pro = Security.getProviders();
    for (Provider p : pro) {
      System.out.println("Provider:" + p.getName() + " - version:" + p.getVersion());
      System.out.println(p.getInfo());
    }
    System.out.println("");
    System.out.println("-------列出系统支持的消息摘要算法：");
    for (String s : Security.getAlgorithms("MessageDigest")) {
      System.out.println(s);
    }
    System.out.println("-------列出系统支持的生成公钥和私钥对的算法：");
    for (String s : Security.getAlgorithms("KeyPairGenerator")) {
      System.out.println(s);
    }

    System.out.println("==============");
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
    cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA".getBytes("UTF-8"), "AES"));

    System.out.println(new String(cipher.doFinal("QWEASDZS".getBytes("UTF-8")), "utf-8"));
  }
}
